///--------------------------------------------------------------------
/// <file name="Xpcom.debug.js">
///   A documentation file to aid VS IntelliSense for the XPCOM
///   interop layer.
///
///   DO NOT INCLUDE IN NAMFOX DISTRIBUTIONS!
/// </file>
///--------------------------------------------------------------------

function $(selector) {
    /// <summary>Retrieves the class object for the specified contract ID.</summary>
    /// <param name="selector">The contract ID for which to retrieve a class object OR an interface ID to retrieve the XPCOM interface for.</param>
    /// <returns type="ComponentClass" />
}

function ComponentClass(contractId) {
    /// <summary>Creates a new ComponentClass instance which facilitates access to common XPCOM functions.</summary>
    /// <param name="contractId" type="String">The contract ID for which to retrieve a class object.</param>
}

ComponentClass.prototype = {
    instance: function(interfaceId) {
        /// <summary>Creates an instance of the component given an interface nsID for that component to conform to.</summary>
        /// <param name="interfaceId" type="String">The ID of the interface that is returned to represent a class instance.</param>
        /// <returns>An instance of a particular class given the specified interface ID.</returns>
    },
    
    service: function(interfaceId) {
        /// <summary>Gets a reference to a particular XPCOM service based on the nsID of an interface for that service to conform to.</summary>
        /// <param name="interfaceId" type="String">The ID of the interface that is returned to represent a service.</param>
        /// <returns>A reference to a particular XPCOM service.</returns>
    }
};

$.cacheHandling = {
    useCache: 0,
    bypassCache: 1
};

$.get = function(url, data, success, error, cacheHandling) {
    /// <summary>Gets data at a specific URL.</summary>
    /// <param name="url" type="String">The URL against which the request will be made.</param>
    /// <param name="data" type="object">A object of data to send.</param>
    /// <param name="success" type="function" optional="true">(Optional) The success callback.</param>
    /// <param name="error" type="function" optional="true">(Optional) The error callback.</param>
    /// <param name="cacheHandling" type="int" optional="true">(Optional) Specifies how to handle Firefox's cache when making a request.</param>
    /// <returns type="nsIXMLHttpRequest" />
};

$.post = function(url, data, success, error, cacheHandling) {
    /// <summary>Posts data to a specific URL.</summary>
    /// <param name="url" type="String">The URL against which the request will be made.</param>
    /// <param name="data" type="object">A object of data to send.</param>
    /// <param name="success" type="function" optional="true">(Optional) The success callback.</param>
    /// <param name="error" type="function" optional="true">(Optional) The error callback.</param>
    /// <param name="cacheHandling" type="int" optional="true">(Optional) Specifies how to handle Firefox's cache when making a request.</param>
    /// <returns type="nsIXMLHttpRequest" />
};

function CustomMessage() {
    /// <summary>Initializes a new instance of the CustomMessage class.</summary>
    /// <field name="key" type="String">The key which identifies this message in the JSON-serialized data in the NAMFox custom message file.</field>
    /// <field name="text" type="String">The text of the message.</field>
}

function NamedCustomMessage() {
    /// <summary>Initializes a new instance of the NamedCustomMessage class.</summary>
    /// <field name="key" type="String">The key which identifies this message in the JSON-serialized data in the NAMFox custom message file.</field>
    /// <field name="text" type="String">The text of the message.</field>
    /// <field name="name" type="String">The title or name of this message.</field>
}

$.messages = {
    backup: function() {
        /// <summary>Backs up the custom messages to a location specified by the user.</summary>
    },
    
    enumerate: function(callback) {
        /// <summary>Enumerates all of the NAMFox custom messages, except for the default message.</summary>
        /// <param name="callback" type="Function">The callback function, invoked for each message.</param>
    },
    
    getDefaultMessage: function() {
        /// <summary>Gets the default custom message.</summary>
        /// <returns type="CustomMessage" />
    },

    getMessage: function(key) {
        /// <summary>Gets the custom message at a particular index.</summary>
        /// <param name="key" type="String">The key for the message to retrieve.</param>
        /// <returns type="NamedCustomMessage"/>
    },
    
    restore: function() {
        /// <summary>
        ///   Restores custom messages from a location specified 
        ///   by the user.
        /// </summary>
    },
    
    save: function() {
        /// <summary>Saves the most recent custom message data to disk.</summary>
    },
    
    size: function() {
        /// <summary>Gets the number of custom messages available.</summary>
        /// <returns type="Number" integer="true" />
    }
};

function Member() {
    /// <field name="customSmileyUrl" type="String">Gets the member's custom smiley URL.</field>
    /// <field name="isModerator" type="Boolean">Specifies whether this member is a moderator.</field>
    /// <field name="userName" type="String">Gets the userName of this member.</field>
}

$.getCurrentUser = function() {
    /// <summary>Gets the currently logged on user.</summary>
    /// <returns type="Member" />
}

$.refreshCurrentUser = function() {
    /// <summary>
    /// Instructs the member service to refresh its information
    /// about the current user.
    /// </summary>
}

$.updateCustomSmileys = function() {
    /// <summary>
    /// Instructs the member service to update the list of custom smileys
    /// that belong to the user.
    /// </summary>
}

$.getConfig = function() {
    /// <summary>Gets the NAMFox configuration object.</summary>
    /// <returns type="NAMFoxConfiguration" />
}

function PrefBranch() {
}

PrefBranch.prototype = {
    addObserver: function(domain, observer, holdWeak) {
        /// <summary>
        /// Adds a preference change observer.
        /// </summary>
        /// <param name="domain" type="String">
        /// The root of an entire branch to observe. e.g. Holding the "root" prefbranch and calling
        /// addObserver("foo.bar.", ...) will observe changes to foo.bar.baz and foo.bar.bzip.
        /// </param>
        /// <param name="observer" type="nsIObserver">The object to be notified if the preference changes.</param>
        /// <param name="holdWeak" type="Boolean">
        /// If true, holds a weak reference to the observer The object must implement the
        /// nsISupportsWeakReference interface or this will fail. If false, holds a strong reference to the observer.
        /// </param>
    },
    
    removeObserver: function(domain, observer) {
        /// <summary>
        /// Removes a preference change observer.
        /// </summary>
        /// <param name="domain" type="String">The preference which is being observed for changes.</param>
        /// <param name="observer" type="nsIObserver">The object to be notified if the preference changes.</param>
    }
};

function NAMFoxConfiguration() {
    /// <field name="autoComplete" type="AutoCompleteBranch">Gets the preference branch which relates to AutoComplete.</field>
    /// <field name="diagnostics" type="DiagnosticsBranch">Gets the preference branch which relates to diagnostics and tracing.</field>
    /// <field name="markup" type="MarkupBranch">Gets the preference branch which relates to markup.</field>
    /// <field name="posts" type="PostBranch">Gets the preference branch which relates to posts.</field>
    /// <field name="privateMessages" type="PrivateMessageBranch">Gets the preference branch which relates to private messages.</field>
    /// <field name="stripMarkup" type="StripMarkupBranch">Gets the preference branch which relates to markup stripping.</field>
    /// <field name="quickEdit" type="QuickEditBranch">Gets the preference branch which relates to Quick Edit.</field>
    /// <field name="quickReply" type="QuickReplyBranch">Gets the preference branch which relates to Quick Reply.</field>
    /// <field name="toolbar" type="ToolbarBranch">Gets the preference branch which relates to the NAMFox toolbar.</field>
    
    /// <field name="registeredVersion" type="String">The latest version that the user has registered.</field>
    /// <field name="shownUpdates" type="String">The latest version that the user has been shown updates for.</field>
}
NAMFoxConfiguration.prototype = new PrefBranch();
NAMFoxConfiguration.prototype.update = function() {
    /// <summary>
    /// Updates all obsoleted preferences to their new equivalents.
    /// </summary>
};

function AutoCompleteBranch() {
    /// <field name="enabled" type="Boolean">Specifies whether AutoComplete is enabled.</field>
    /// <field name="onDemandOnly" type="Boolean">Specifies whether AutoComplete appears only on demand e.g. only when
    /// the user specifically requests for AutoComplete (with Ctrl+Space, for example).</field>
}
AutoCompleteBranch.prototype = new PrefBranch();

function DiagnosticsBranch() {
    /// <field name="assertUIEnabled" type="Boolean">Specifies whether assertion failures are displayed to the user in an alert window.</field>
    /// <field name="exceptionUIEnabled" type="Boolean">Specifies whether exceptions are displayed to the user in an alert window. This has no effect if the traceLevel is Off (i.e. 0).</field>
    /// <field name="traceLevel" type="Number" integer="true">Specifies the trace level for tracing in NAMFox. See nfxITrace for trace level constants.</field>
    /// <field name="traceRequests" type="Boolean">Specifies whether NAMFox traces HTTP requests.</field>
}
DiagnosticsBranch.prototype = new PrefBranch();

function MarkupBranch() {
    /// <field name="anchor" type="Boolean">Specifies whether the anchor button appears in most user interfaces.</field>
    /// <field name="code" type="Boolean">Specifies whether the code button appears in most user interfaces.</field>
    /// <field name="customMessages" type="Boolean">Specifies whether the custom message drop-down list appears in most user interfaces.</field>
    /// <field name="horizontalRule" type="Boolean">Specifies whether the horizontal rule (HR) button appears in most user interfaces.</field>
    /// <field name="indent" type="Boolean">Specifies whether the indent (UL) button appears in most user interfaces.</field>
    /// <field name="privateMessageLink" type="Boolean">Specifies whether the private message link button appears in most user interfaces. This button assists in sending the PM because it prompts for the user name, subject, and message.</field>
    /// <field name="privateMessageShortHand" type="Boolean">Specifies whether the PM markup button appears in most user interfaces.</field>
    /// <field name="php" type="Boolean">Specifies whether the PHP button appears in most user interfaces.</field>
    /// <field name="pre" type="Boolean">Specifies whether the pre button appears in most user interfaces.</field>
    /// <field name="profile" type="Boolean">Specifies whether the profile markup button appears in most user interfaces.</field>
    /// <field name="replace" type="Boolean">Specifies whether the find/replace button appears in most user interfaces.</field>
    /// <field name="strike" type="Boolean">Specifies whether the strike button appears in most user interfaces.</field>
    /// <field name="subscript" type="Boolean">Specifies whether the subscript button appears in most user interfaces.</field>
    /// <field name="superscript" type="Boolean">Specifies whether the superscript button appears in most user interfaces.</field>
    /// <field name="videos" type="Boolean">Specifies whether the video drop-down list appears in most user interfaces.</field>
}
MarkupBranch.prototype = new PrefBranch();

function StripMarkupBranch() {
    /// <field name="colorLightness" type="Number" integer="true">The lower-bound lightness percentage of colors to strip.</field>
    /// <field name="stripOptions" type="Number" integer="true">Specifies which markup to strip from posts.</field>
}
StripMarkupBranch.prototype = new PrefBranch();

function PrivateMessageBranch() {
    /// <field name="readReceipt" type="Boolean">Specifies whether the "Get a receipt when recipient reads message" check box on the reply-to PM screen is checked by default.</field>
}
PrivateMessageBranch.prototype = new PrefBranch();

function QuickEditBranch() {
    /// <field name="doubleClickEnabled" type="Boolean">Specifies whether users can double click on a post to go into Quick Edit mode.</field>
    /// <field name="disableDoubleClickForPostsWithMedia" type="Integer">Specifies whether to disable double click invoking quick edit when the post has video content.
    /// -1 means undefined, 0 means false, and 1 means true.</field>
}
QuickEditBranch.prototype = new PrefBranch();

function QuickReplyBranch() {
    /// <field name="enabled" type="Boolean">Specifies whether the NAMFox Quick Reply is enabled.</field>
    /// <field name="rememberMessage" type="Boolean">Specifies whether NAMFox should remember your Quick Reply message for each thread you visit if you don't submit it. This is useful in case a user accidentally navigates away from a page without submitting the Quick Reply.</field>
    /// <field name="textAreaHeight" type="Number" integer="true">The height of the text area for Quick Reply.</field>
    /// <field name="textAreaWidth" type="String">The width of the text area for Quick Reply (percentage-based).</field>
    /// <field name="useSignatureChecked" type="Boolean">Specifies whether the "Use Signature?" check box is checked by default.</field>
}
QuickReplyBranch.prototype = new PrefBranch();

function ToolbarBranch() {
    /// <field name="enabledSmileys" type="String">Specifies the smileys that are enabled.</field>
    /// <field name="linkBehavior" type="LinkBehavior">Specifies the behavior for opening links in the toolbar.</field>
}
ToolbarBranch.prototype = new PrefBranch();

var LinkBehavior = {
    OpenInNewTabWithMiddleClick: 1,
    AlwaysOpenInNewTab: 2
};

var StripOptions = {
    Color: 1,
    SizeOne: 2,
    Sub: 4,
    Sup: 8
};

$.dataKeys =  {
    /// <field name="quickReplyMessage" type="String">The key to access old messages left that the user has typed in the Quick Reply text area without submitting them.</field>
    quickReplyMessage: "QRM"
};

$.dataRepository = {
    getData: function(key) {
        /// <summary>Gets arbitrary data from the data repository based on the key.</summary>
        /// <param name="key" type="String">The key of the data to retrieve. The $.dataKeys variable has well-known keys whose values already exist in the repository.</param>
        /// <returns type="Object" />
        
    },
    
    setData: function(key, data) {
        /// <summary>Sets arbitrary data in the data repository based on the key.</summary>
        /// <param name="key" type="String">The key of the data to set. The $.dataKeys variable has well-known keys whose values already exist in the repository.</param>
        /// <param name="data" type="Object">The data to set</param>
        
    }
};

$.trace = {
    traceLevel: 0,
    
    assert: function(condition, message) {
        /// <summary>Checks for a condition and pops up an alert window if that condition is false.</summary>
        /// <param name="condition" type="Boolean">True to prevent a message being displayed; otherwise, false.</param>
        /// <param name="message" type="String">A message to display.</param>
    },
    
    dumpStackTrace: function() {
        /// <summary>Dumps the current stack trace to the console.</summary>
        
    },
    
    error: function(e) {
        /// <summary>Logs an exception as an error to the JS Console.</summary>
        /// <param name="e" type="Error">The exception to log.</param>
    },
    
    fail: function(message) {
        /// <summary>Emits the specified error message.</summary>
        /// <param name="message" type="String">A message to display.</param>
    },
    
    info: function(message) {
        /// <summary>Logs a message to the JS Console and the dump window as an informational message.</summary>
        /// <param name="message" type="String">The message to write.</param>
    },
    
    warn: function(e) {
        /// <summary>Logs an exception to the JS console as a warning.</summary>
        /// <param name="e" type="Error">The exception to log.</param>
    },
    
    verbose: function(message) {
        /// <summary>Logs a message to the JS Console and the dump window as a verbose message.</summary>
        /// <param name="message">The message to write.</param>
    }
};

$.traceLevels = {
    Off: 0,
    TraceError: 1,
    TraceWarning: 2,
    TraceInfo: 3,
    TraceVerbose: 4
};

$.assert = $.trace.assert;
$.error = $.trace.error;
$.fail = $.trace.fail;
$.info = $.trace.info;
$.warn = $.trace.warn;
$.verbose = $.trace.verbose;

// Text Transformers
$.transformers = {
    gamespot: function(url) {
        /// <summary>Transforms Gamespot video URLs to a format consumable by the [gamespot] nTag.</summary>
        /// <param name="url" type="String">The URL to transform.</param>
        /// <returns type="String" />
    },
    
    gametrailers: function(url) {
        /// <summary>Transforms Gametrailers video URLs to a format consumable by the [gametrailers] nTag.</summary>
        /// <param name="url" type="String">The URL to transform.</param>
        /// <returns type="String" />
    },
    
    gametrailersUser: function(url) {
        /// <summary>Transforms user Gametrailers video URLs to a format consumable by the [gametrailers_uservideo] nTag.</summary>
        /// <param name="url" type="String">The URL to transform.</param>
        /// <returns type="String" />
    },
    
    gamevideos: function(url) {
        /// <summary>Transforms Gamevideos video URLs to a format consumable by the [gamevideos] nTag.</summary>
        /// <param name="url" type="String">The URL to transform.</param>
        /// <returns type="String" />
    },
    
    youtube: function(url) {
        /// <summary>Transforms Youtube video URLs to a format consumable by the [youtube] nTag.</summary>
        /// <param name="url" type="String">The URL to transform.</param>
        /// <returns type="String" />
    }
};

$.attrEncode = function(s) {
    /// <summary>
    /// Encodes a string so that it can be used in an HTML literal as an attribute.
    /// </summary>
    /// <param name="s">The string to encode.</param>
        
};
$.urlEncode = function(s) {
    /// <summary>
    /// Encodes a string so that it is compatible with use in a URL.
    /// </summary>
    /// <param name="s">The string to encode.</param>
    
};

$.url = {
    api: function(path) {
        /// <summary>
        /// Resolves a URL to the Neoseeker API, given the specified URI path.
        /// </summary>
        /// <param name="path">The path of the URI, to be combined with the root
        /// for the API.</param>
    },

    blog: function(path) {
        /// <summary>
        /// Resolves a URL to the blog pages, given the specified URI path.
        /// </summary>
        /// <param name="path">The path of the URI, to be combined with the root
        /// URI for blogs.</param>
    },

    forum: function(path) {
        /// <summary>
        /// Resolves a URL to the forum pages, given the specified URI path.
        /// </summary>
        /// <param name="path">The path of the URI, to be combined with the root
        /// URI for forums.</param>
    },

    image: function(path) {
        /// <summary>
        /// Resolves a URL to Neoseeker images, given the specified URI path.
        /// </summary>
        /// <param name="path">The path of the URI, to be combined with the root
        /// URI for images.</param>
    },

    member: function(path) {
        /// <summary>
        /// Resolves a URL to the member pages, given the specified URI path.
        /// </summary>
        /// <param name="path">The path of the URI, to be combined with the root
        /// URI for members.</param>
    },
};

$.createCallback = function(callback, context) {
    return function() {
        callback.apply(context, arguments);
    };
};

$.dumpObject = function(o) {
    for (var i in o) {
        if (o.hasOwnProperty(i)) {
            $.verbose(i + " : " + o[i]);
        }
    }
};

$.fxVersion = {
    equals: function(version) {
    },
    
    lessThanOrEqualTo: function(version) {
    },
    
    greaterThanOrEqualTo: function(version) {
    }
};

$.contains = function(str, substring) {
    /// <summary>Returns a value indicating whether the specified String object occurs within this string.</summary>
    /// <param name="str" type="String">The String object in which to search for the substring.</param>
    /// <param name="substring" type="String">The String object to seek.</param>
    /// <returns type="Boolean" />

    return str.indexOf(substring) !== -1;
};

$.toRegExp = function(str, flags) {
    /// <summary>Converts a string into a regular expression (RegExp) object.</summary>
    /// <param name="str" type="String">The String object to convert to a RegExp.</param>
    /// <param name="flags" optional="true">(Optional) Flags to pass to the RegExp constructor.</param>
    /// <returns type="RegExp" />

    return new RegExp(str.replace(/([\\\^\$*+[\]?{}.=!:(|)])/g, "\\$1"), flags || "");
};

$.repeat = function(original, count) {
    /// <summary>
    ///   Creates a string by repeating the given string
    ///   a certain number of times.
    /// </summary>
    /// <param name="original" type="String">
    ///   The original string to repeat a certain number of times.
    /// </param>
    /// <param name="count" type="Number" integer="true">
    ///   The number of times the original string will occur in the result string.
    /// </param>
    /// <returns type="String" />

    var retVal = [];
    for (var i = 0; i < count; ++i) {
        retVal.push(original);
    }
    return retVal.join("");
};

$.startsWith = function(str, substring) {
    /// <summary>Determines whether the beginning of this instance matches the specified string.</summary>
    /// <param name="str" type="String">The String object in which to search for the substring.</param>
    /// <param name="substring" type="String">The String object to seek.</param>
    /// <returns type="Boolean" />

    return str.indexOf(substring) === 0;
};

$.endsWith = function(str, substring) {
    /// <summary>Determines whether the end of this instance matches the specified string.</summary>
    /// <param name="str" type="String">The String object in which to search for the substring.</param>
    /// <param name="substring" type="String">The String object to seek.</param>
    /// <returns type="Boolean" />

    return str.indexOf(substring) === str.length - substring.length;
};

$.trim = function(str) {
    /// <summary>Removes all occurrences of white space characters from the beginning and end of this instance.</summary>
    /// <param name="str" type="String">The String object from which to trim whitespace.</param>
    /// <returns type="String" />

    return str.replace(/^\s+|\s+$/g, "");
};

$.padLeft = function(str, totalWidth, paddingChar) {
    /// <summary>
    /// Right-aligns the characters in this instance, padding on the left
    /// with a specified character for a specified total length.
    /// </summary>
    /// <param name="str" type="String">The String object to pad from the left.</param>
    /// <param name="totalWidth" type="Number">
    /// The number of characters in the resulting string, equal to the
    /// number of original characters plus any additional padding characters.
    /// </param>
    /// <param name="paddingChar" type="String">
    /// A padding character.
    /// </param>
    /// <returns type="String" />

    paddingChar = paddingChar || ' ';
    if (paddingChar.length !== 1) {
        paddingChar = paddingChar[0];
    }

    var padLength = totalWidth - this.length;
    if (padLength > 0) {
        return $.repeat(paddingChar, padLength) + str;
    }

    return str;
};